<template>
  <div>
    <div class="footer_wrap">
      <!-- <router-link to="/find" exact>发现音乐</router-link> -->
      <!-- <router-link to="/my" exact>我的音乐</router-link> -->
      <!-- 以query方式传参 -->
      <!-- <router-link to="/part?username=harry&password=123">朋友</router-link> -->
      <!-- 以params传参 -->
      <!-- <router-link to="/part/harry/123">朋友</router-link> -->

      <span @click="fn('/find', 'find')">发现音乐</span>
      <span @click="fn('/my', 'my')">我的音乐</span>
      <span @click="fn('/part', 'part')">朋友</span>
      <span
        @click="
          $router.push(
            { name: 'part', query: { username, password } },
            () => {}
          )
        "
        >朋友-query</span
      >
      <span @click="fn2('/part', 'part')">朋友-params</span>
    </div>
    <div class="top">
      <!-- 一级路由出口 -->
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: 'harry',
      password: '123',
    }
  },

  methods: {
    fn(path, name) {
      this.$router.push(
        {
          // path: '/find',
          name,
        },
        //为了防止导航冗余的报错
        () => {}
      )
    },

    fn1(path, name) {
      //通过query传参
      this.$router.push(
        {
          name,
          query: {
            username: this.username,
            password: this.password,
          },
        },
        () => {}
      )
    },

    fn2(path, name) {
      //通过params传参
      this.$router.push(
        {
          path,
          // name,
          params: {
            username: 'harry',
            password: '123',
          },
        },
        () => {}
      )
    },
  },
}
</script>

<style scoped>
/* .router-link-exact-active,
.router-link-active {
  background-color: #555 !important;
} */

.aa,
.bb {
  background-color: #087 !important;
}

.footer_wrap {
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  width: 100%;
  text-align: center;
  background-color: #333;
  color: #ccc;
}
.footer_wrap a,
.footer_wrap span {
  flex: 1;
  text-decoration: none;
  padding: 20px 0;
  line-height: 20px;
  background-color: #333;
  color: #ccc;
  border: 1px solid black;
}
.footer_wrap a:hover {
  background-color: #555;
}
.top {
  padding-top: 62px;
}
</style>
